/*
 * @Author: lee
 * @Date: 2024-01-15 09:39:24
 * @LastEditors: lee
 * @LastEditTime: 2024-01-16 18:02:36
 * @Description: file content
 */
import i18n from "./i18n.js";
// const env = require('.env');
import env from "./env.js";
const path = require('path');
export default {
  server: {
    port: 4001, // default: 3000
    host: "0.0.0.0", // default: localhost
    // proxy: {
    //   '/api': {
    //     changeOrigin: true,
    //     target: 'http://192.168.1.132:3000', // 允许跨域的服务器地址
    //     pathRewrite: {
    //       '^/api': ''
    //     }
    //   }
    // }
  },
  env: env[process.env.NODE_ENV],
  srcDir: "./src",
  //全局SEO设置
  head: {
    title: "nuxt2 模板",
    htmlAttrs: {
      lang: "en",
    },
    meta: [
      { charset: "utf-8" },
      { name: "viewport", content: "width=device-width, initial-scale=1" },
      { hid: "description", name: "description", content: "Nuxt2 Template system" },
    ],
    link: [
      { rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
      //reset重置
      { rel: 'stylesheet', type: 'text/css', href: '/css/reset.css' },
      { rel: 'stylesheet', type: 'text/css', href: '/css/zoom.css' }
    ],
  },
  //全局样式配置
  css: [
    "normalize.css",
    '~/assets/css/tailwind.css',
    "element-ui/lib/theme-chalk/index.css",
    'element-ui/lib/theme-chalk/display.css'
  ],

  //插件配置
  plugins: [
    //{ src: "~/plugins/store-cache.js", ssr: false },
    "~/plugins/element.js",
    "~/plugins/axios.js",
    "~/plugins/api.js",
    "~/plugins/cache.js",
    { src: "~/plugins/download.js", ssr: false },
    { src: "~/plugins/modal.js", ssr: false },
    { src: "~/plugins/jsencrypt.js", ssr: false },
    { src: '~/plugins/icons', ssr: true },
    { src: '~/plugins/vuex-persistedstate.js', ssr: false },
  ],

  //自动导入组件
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: ['@nuxtjs/tailwindcss'],

  //模块
  modules: ["@nuxtjs/axios", '@nuxtjs/proxy', 'cookie-universal-nuxt', ["@nuxtjs/i18n", i18n]],

  axios: {
    baseURL: env[process.env.NODE_ENV].ENV_API,
  },

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    vendor: ["element-ui"],
    extend(config, ctx) {
      // ...
      const svgRule = config.module.rules.find((rule) =>
        rule.test.test(".svg")
      );
      svgRule.exclude = [path.resolve(__dirname, "./src/static/svg")];
      config.module.rules.push({
        test: /\.svg$/,
        include: [path.resolve(__dirname, "./src/static/svg")],
        loader: "svg-sprite-loader",
        options: {
          symbolId: "icon-[name]",
        },
      });
    },
  },
  router: {
    middleware: [ "auth"],
  },
  tailwindcss: {
    cssPath: '~/assets/css/tailwind.css',
    configPath: 'tailwind.config.js',
    exposeConfig: false,
    config: {}
  },


};
